package ar.com.e2solver.view;

import java.awt.GridLayout;
import java.awt.Panel;

import ar.com.e2solver.model.Puzzle;

public class PuzzleView extends Panel {
	
	private static final long serialVersionUID = 1L;
	private Puzzle puzzle;

	public PuzzleView(Puzzle puzzleToResolve) {
		this.puzzle = puzzleToResolve;
		initialize();
	}

	private void initialize() {
		GridLayout gl = new GridLayout(this.puzzle.getRowsNumber(), this.puzzle.getColumnNumbers());
		this.setLayout(gl);
		
		for (int x = 0; x < this.puzzle.getRowsNumber(); x++) {
			for (int y = 0; y < this.puzzle.getColumnNumbers(); y++) {
				this.add(new PieceView(this.puzzle.getPieceAt(x, y)));
			}
		}		
	}

}
